package com.opeartion.service.impl;

import com.opeartion.dao.RankMapper;
import com.opeartion.pojo.Category;
import com.opeartion.service.RankService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author sanshi
 * @version 1.0
 * @data 2020/6/6-20:01
 */

@Service
public class RankServiceImpl implements RankService {
    /**
     * 查询
     * @return
     */
    @Autowired
    private RankMapper rankMapper;

    @Override
    public List<Category> findCategory() {
       return rankMapper.findCategory();
    }

    @Override
    public List<Category> findCategory(String name) {
        return  rankMapper.findCategory(name);
    }

    /**
     * 添加
     * @param category
     */

    @Override
    public void updateCategory(Category category) {
        Map map = new HashMap();
        map.put("id",category.getTb_id());
        map.put("name",category.getTb_name());
        map.put("num",category.getGoods_num());
        rankMapper.updateCategory(map);
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @Override
    public int deleteCategory(int id) {
        return rankMapper.deleteCategory(id);
    }



}
